home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / CTRLBA.PAK / CTRLBARS.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  107 lines

  1. // ctrlbars.cpp : Defines the class behaviors for the application.
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include <afxpriv.h>    // for idle-update windows message
  15.  
  16. #include "ctrlbars.h"
  17. #include "mainfrm.h"
  18.  
  19. #ifdef _DEBUG
  20. #undef THIS_FILE
  21. static char BASED_CODE THIS_FILE[] = __FILE__;
  22. #endif
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CCtrlbarsApp
  26.  
  27. BEGIN_MESSAGE_MAP(CCtrlbarsApp, CWinApp)
  28.     //{{AFX_MSG_MAP(CCtrlbarsApp)
  29.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  30.     //}}AFX_MSG_MAP
  31. END_MESSAGE_MAP()
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CCtrlbarsApp construction
  35.  
  36. CCtrlbarsApp::CCtrlbarsApp()
  37. {
  38.     // Place all significant initialization in InitInstance
  39. }
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // The one and only CCtrlbarsApp object
  43.  
  44. CCtrlbarsApp NEAR theApp;
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CCtrlbarsApp initialization
  48.  
  49. BOOL CCtrlbarsApp::InitInstance()
  50. {
  51.     // Standard initialization
  52.  
  53.     Enable3dControls(); // use 3d controls in dialogs
  54.  
  55.     // create a new SDI main frame window
  56.     CFrameWnd* pMainFrame = new CMainFrame;
  57.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  58.         return FALSE;
  59.     pMainFrame->ShowWindow(m_nCmdShow);
  60.     pMainFrame->UpdateWindow();
  61.     m_pMainWnd = pMainFrame;
  62.  
  63.     pMainFrame->SendMessage(WM_COMMAND, IDM_VIEWPALETTE, (LPARAM)0);
  64.     return TRUE;
  65. }
  66.  
  67.  
  68. // In this override of OnIdle we are doing UI for our app.
  69. // Since this needs to be as fast as possible to give the user
  70. // the best result we do our updates first when lCount is zero
  71. // then we call the library to do its work.
  72. BOOL CCtrlbarsApp::OnIdle(LONG lCount)
  73. {
  74.     if (lCount == 0)
  75.     {
  76.         ASSERT(m_pMainWnd != NULL);
  77.  
  78.         // look for any top-level windows owned by us
  79.         // we use 'HWND's to avoid generation of too many temporary CWnds
  80.         for (HWND hWnd = ::GetWindow(m_pMainWnd->m_hWnd, GW_HWNDFIRST);
  81.                 hWnd != NULL; hWnd = ::GetNextWindow(hWnd, GW_HWNDNEXT))
  82.         {
  83.             if (::GetParent(hWnd) == m_pMainWnd->m_hWnd)
  84.             {
  85.                 // if owned window is active, move the activation to the
  86.                 //   application window
  87.                 if (GetActiveWindow() == hWnd && (::GetCapture() == NULL))
  88.                     m_pMainWnd->SetActiveWindow();
  89.  
  90.                 // also update the buttons for the top-level window
  91.                 SendMessage(hWnd, WM_IDLEUPDATECMDUI, (WPARAM)TRUE, 0L);
  92.             }
  93.         }
  94.     }
  95.     return CWinApp::OnIdle(lCount);
  96. }
  97.  
  98. /////////////////////////////////////////////////////////////////////////////
  99. // CCtrlbarsApp commands
  100.  
  101. void CCtrlbarsApp::OnAppAbout()
  102. {
  103.     CDialog(IDD_ABOUTBOX).DoModal();
  104. }
  105.  
  106. /////////////////////////////////////////////////////////////////////////////
  107.